﻿@using CloudNimble.BlazorEssentials
@using System.Security.Claims
@inherits LayoutComponentBase
@inject AppState appState
@inject NavigationManager navManager
@*@inject AuthenticationStateProvider AuthenticationStateProvider
*@

<div class="page">
    <div class="sidebar">
        <NavMenu />
    </div>

    <div class="main">
        <div class="top-row px-4">
            <h1>
                @if (!string.IsNullOrWhiteSpace(appState.CurrentNavItem?.PageIcon))
                {
                    <i class="@appState.CurrentNavItem?.PageIcon"></i>
                }
                @appState.CurrentNavItem?.PageTitle
            </h1>
            <div class="profile-actions">
                @*            <AuthorizeView>
                    <a href="#" data-toggle="popover" data-placement="bottom" data-popover-content="#profile-menu">
                    <div class="profile-picture">
                    <img src="@context.User.FindFirst("picture")?.Value" />
                    </div>
                    </a>
                    </AuthorizeView>
                *@
            </div>
        </div>

        <div class="content px-4">
            @Body
        </div>
    </div>
</div>

@code
{

    //[CascadingParameter]
    //private Task<AuthenticationState> authenticationStateTask { get; set; }

    protected override void OnParametersSet()
    {
        appState.SetCurrentNavItem();
    }

    protected override async Task OnInitializedAsync()
    {
        appState.StateHasChangedAction += StateHasChanged;
        //appState.AuthenticationStateProvider = AuthenticationStateProvider;
        //await appState.LoadCoreData();
    }

    public void Dispose()
    {
        appState.StateHasChangedAction -= StateHasChanged;
    }

}